<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        function myNew(Fn){
            //内部创建一个空对象
            const obj = {}
            //将函数的显示原型指向对象的隐式原型
            Fn.protoType = obj.__proto__
            //更改this的指向
            const res = Fn.call(obj)
            //判断返回的结果是不是一个对象
            return typeof res === 'object' ?res : obj
        }

        function fun(){
            this.a = 1
        }

        console.log(myNew(fun));
    </script>

</body>
</html>